<?php
class otherService extends commonService{
    private $table=null;
	
	
    public function __construct(){
        parent::__construct();
        
    }
	//更新common.js
	public function update_js_($file,$file2){
		$config=$this->conf;
		
		/*
		if(window.location.href.indexOf("{cms.com/}") != -1){
			document.domain = "{cms.com/}";
		}
		var website_url= '{http://www.cms.com/}';
		var CKDomain = "{.cms.com/}";
		var CKPath = "{CKPath/}";
		var CKPrex = "{CKPrex/}";
		*/
		$sample=file_get_contents($file);
		
		$search=array(
			'{cms.com/}',
			'{http://www.cms.com/}',
			'{.cms.com/}',
			'{CKPath/}',
			'{CKPrex/}'
		);
		$replace=array(
			ltrim($config->cookie_domain,'.'),
			$config->WEB['url'],
			$config->cookie_domain,
			$config->cookie_path,
			$config->cookie_prefix
		);
		
		$content=str_replace($search,$replace,$sample);
		
		return file_put_contents($file2,$content);
	}
    public function _comment($table){
        $query="SELECT `column_name` , `column_comment` FROM `Information_schema`.`columns` WHERE `table_Name` = '{$table}'";
        $result=$this->m->query($query);
        $d=array();
        if($result){
            while($row=$this->m->fetch_assoc($result)){
                $d[$row['column_name']]=$row['column_comment'];
            }
            $this->m->free_result($result);
        }
        return $d;
    }
    public function help_($tabName){
        $result=$this->m->query("desc {$tabName}");
        $fields=array();
        if($result){
            $_SESSION['prohelp']['table']=$tabName;
            while($row=$this->m->fetch_assoc($result)){
                $row['Field']=strtolower($row['Field']);
                $row['length']=0;
                if(preg_match('/(?:varchar|char)\((\d+)\)/i',$row['Type'],$matches)){
                    $row['length']=$matches[1];
                }
                $fields[]=$row;
            }
            $this->m->free_result($result);
        }
        return $fields;
    }
    public function help2_($data){
        
        unset($_SESSION['prohelp']);
        return $data;
    }
    public function file_detail($folder){
        $out=array();
        foreach($folder as $f){
            $out[$f]=array();
        }
        return $out;
        foreach($folder as $f){
            $out[$f]=array();
            $PATH=PROJECT_PATH.$f.'/';
            if(!file_exists($PATH)) continue;
            $files=scandir($PATH);
            foreach($files as $file){
                if($file=='.' or $file=='..') continue;
                if(is_dir($PATH.$file)) continue;
                $out[$f][$file]=htmlspecialchars(file_get_contents($PATH.$file),ENT_QUOTES);
            }
        }
        return $out;
    }
}